﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using System.Windows.Media;

namespace Studio77.RuneMaster.Views
{
    public partial class ScoreView : UserControl
    {
        public ScoreView()
        {
            InitializeComponent();
        }


        private void SetUI(int score, int duplex, int combo)
        {
            this.txtScore.Text = "+" + score;

            if (score > 1600)
            {
                txtScore.Foreground = BrushHigh4;
            }
            else if (score > 1000)
            {
                txtScore.Foreground = BrushHigh3;
            }
            else if (score > 400)
            {
                txtScore.Foreground = BrushHigh2;
            }
            else if (score > 100)
            {
                txtScore.Foreground = BrushHigh1;
            }
            else
            {
                txtScore.Foreground = BrushNormal;
            }

            string uri = string.Empty;
            switch (duplex)
            {
                case 1:
                    uri = "/Images/eliminate_single.png";
                    break;
                case 2:
                    uri = "/Images/eliminate_double.png";
                    break;
                case 3:
                    uri = "/Images/eliminate_triple.png";
                    break;
                case 4:
                    uri = "/Images/eliminate_four.png";
                    break;
            }
            BitmapImage bitmap = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
            imgDuplex.Source = bitmap;

            if (combo < 2)
            {
                this.imgCombo.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                this.imgCombo.Visibility = System.Windows.Visibility.Visible;
                this.txtCombo.Text = combo.ToString();
            }
        }

        /// <summary>
        /// 显示分数
        /// </summary>
        public void ShowScore(int score, int duplex, int combo)
        {
            SetUI(score, duplex, combo);
            this.StoryboardShow.Begin();
        }
    }
}
